package br.ufrgs.dbproject.idgenerator.dewey;

import br.ufrgs.dbproject.Context;
import br.ufrgs.dbproject.idgenerator.IDGeneratorStrategy;

public class ChildIDGenerator implements IDGeneratorStrategy<DeweyID> {

	public boolean canHandle(Context<DeweyID> context) {
		
		if (context.getLastSavedID().isEmpty()) {
			return false;
		}
		
		return context.getLastSavedID().getDeep() == context.getSize();
	}

	public DeweyID generate(Context<DeweyID> context) {
		return context.getLastSavedID().createFirstChildID();
	}

}
